package cn.psvmc.cxzapi.task;

import cn.psvmc.cxzapi.mapper.store.TCouponMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * @Author YWX
 * @Classname CouponTask
 * @Description 优惠券定时任务
 * @Date 2024/11/2 21:38
 **/
@Slf4j
@Component
public class CouponTask {
    @Resource
    private TCouponMapper couponMapper;

    /**
     * @Author YWX
     * @Classname CouponTask
     * @Description 定时任务更新优惠券状态--每隔1分钟触发
     * @Date 2024/11/2 21:39
     **/
    @Async("threadPoolTaskScheduler")
    @Scheduled(cron = "${cron.cancelOrder}")
    public void updateCouponDeleted() {
        couponMapper.updateCouponDeleted(LocalDateTime.now());
        couponMapper.updateCustomerUsed(LocalDateTime.now());
    }
}
